package com.sxbang.bms.controller;

import com.alibaba.fastjson.JSON;
import com.sxbang.bms.config.jwt.JwtUtils;
import com.sxbang.bms.model.SysUser;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lmm
 * @date 2019/4/12 0012  15:56.
 */
@RestController
public class TestController {

    @PostMapping(value = {"/sign-in"})
    public String  signIn(SysUser sysUser){
        System.out.println("登录接口===="+ JSON.toJSONString(sysUser));
        String username=sysUser.getUsername();
        String password=sysUser.getPassword();

//        userService.signIn(sysUser);

//        String token= JWTUtil.sign(username,password);
        String token= JwtUtils.getToken(username);
        System.out.println("生成token=="+token);
        //System.out.println("返回数据="+ResponseResult.e(ResponseCode.SIGN_IN_OK,((JwtToken) SecurityUtils.getSubject().getPrincipal()).getToken()));

        return token;
    }

}
